package WaiBao;

import java.util.Arrays;

public class GongYanFong {
    public static void main(String[] args) {
        String[] name = {"纪伯伦(班长)","董卿(组织委员)", "小李(学习委员)","张凯丽(文艺委员)", "李大勇", "张长岭", "陈勇", "黄毛", "李耀宇", "严祥", "陈质量", "许可",
                "赵德顺", "李富贵", "小胖", "小墩墩", "王战", "王一博", "王珂", "郭辉", "李慧超", "李大咏", "萧敬腾", "李德伦", "赵超华", "金庸", "包贝尔", "郑凯",
                "肖战", "公冶峰 (学生)"};//考生本人: 公冶峰 (学生)
        int[] age = {19, 21, 20, 19, 18, 20, 19, 21, 19, 19, 18, 18, 18, 20, 20, 19, 18, 18, 18, 18, 19, 19, 20, 20, 20, 18, 20, 18, 18, 19};//最后一位考生本人：年龄:19
        double[] H1 = {88, 72, 86, 84, 77, 69, 78, 89, 81, 80, 91, 87, 85, 79, 65, 68, 99, 99, 96, 88, 92, 91, 95, 65, 75, 74, 94, 74, 88, 95};
        double[] H2 = {89, 65, 85, 66, 68, 67, 68, 69, 80, 70, 90, 77, 66, 85, 65, 65, 76, 99, 66, 98, 72, 71, 95, 86, 75, 88, 84, 64, 80, 96};
        double[] H3 = {84, 77, 84, 75, 75, 64, 78, 69, 80, 80, 93, 87, 85, 65, 65, 68, 69, 96, 96, 93, 92, 81, 65, 95, 76, 84, 73, 71, 89, 94};

        double demo1 ;//代表每个学生的总分
        double jieguo1;//代表每个学生的平均分
//        for (int i = 0; i < 30; i++) {
//            demo1 = H1[i] + H2[i] + H3[i];
//            jieguo1 = (demo1 * 1.0) / 3;
//            System.out.println(name[i] + "的总分为:" + demo1);
//            System.out.println(name[i] + "的平均分为:" + jieguo1);
//        }


        double E = 0, R = 0;
        double[] SHUZU = new double[30];
//        for (int i = 0; i < 30; i++) {
//            E = H1[i] + H2[i] + H3[i];
//            R= (E * 1.0) / 3;
//            SHUZU[i] = R;
//        }
//
//        for (int i = 0; i <  SHUZU.length - 1; i++) {
//            for (int j = 0; j <  SHUZU.length - i - 1; j++) {
//                if (SHUZU[j] < SHUZU[j + 1]) {
//                    double tep =  SHUZU[j];
//                    SHUZU[j] = SHUZU[j + 1];
//                    SHUZU[j + 1] = tep;
//                }
//            }
//        }
//        System.out.println("前十名同学的成绩为:");
//        for (int i = 0; i < 10; i++) {
//            System.out.println( SHUZU[i]);
//        }



        double RR1 = 0, RR2 = 0, RR3 = 0;//计算每门课的平均分
        double DO1 = 0, DO2 = 0, DO3 = 0;//计算每门课标准差
        double CV1 = 0, CV2 = 0, CV3 = 0;//计算每门课中位数
        double he = 0;
        for (int i = 0; i < H1.length; i++) {
            he += H1[i];
        }
        RR1 = (he * 1.0) / 30;
        System.out.println("农业设施及环境调控的班级平均分为:" +RR1);
        double Sum = 0;
        for (int i = 0; i < H2.length; i++) {
            Sum += H2[i];
        }
        RR2 = (Sum * 1.0) / 30;
        System.out.println("农业设施设计与建造的班级平均分为:" + RR2);
        double sum = 0;
        for (int i = 0; i < H3.length; i++) {
            sum += H3[i];
        }
        RR3 = (sum * 1.0) / 30;
        System.out.println("园艺植物设施栽培学的班级平均分为:" + RR3);



        double c1 = 0, c2 = 0, c3 = 0;
        for (int i = 0; i < H1.length; i++) {
            c1 += (H1[i] - RR1) * (H1[i] - RR1);
        }
        DO1 = Math.sqrt(c1*1.0/30);
        System.out.println("农业设施及环境调控的班级标准差为:" + DO1);
        for (int i = 0; i <H2.length; i++) {
            c2 += (H2[i] - RR2) * (H2[i] -RR2);
        }
        DO2 = Math.sqrt(c2*1.0/30);
        System.out.println("农业设施设计与建造的班级标准差为:" +DO2);

        for (int i = 0; i < H3.length; i++) {
            c3 += (H3[i] - RR3) * (H3[i] - RR3);
        }
        DO3 = Math.sqrt(c3*1.0/30);
        System.out.println("园艺植物设施栽培学的标准差为:" + DO3);

//
//        Arrays.sort(H1);
//        Arrays.sort(H2);
//        Arrays.sort(H3);
//        CV1 = (H1[15] + H2[14]) * 1.0 / 2;
//        CV2 = (H2[15] +H2[14]) * 1.0 / 2;
//        CV3 = (H3[15] + H3[14]) * 1.0 / 2;
//        System.out.println("农业设施及环境调控的中位数为:" + CV1);
//        System.out.println("农业设施设计与制造的中位数为:" + CV2);
//        System.out.println("园艺植物设施栽培学的中位数为:" + CV3);

    }
}
